package de.toolschmied.jjas.client.cms.actions;

import de.toolschmied.jjas.client.cms.actions.AlignmentAction.AlignmentListener;
import de.toolschmied.jjas.client.widgets.toolbar.Action;
import de.toolschmied.jjas.client.widgets.toolbar.Toolbar;

public class AlignmentToolbar extends Toolbar {

	public AlignmentToolbar(AlignmentListener listener) {
		for (Alignment alignment : Alignment.values()) {
			AlignmentAction action = new AlignmentAction(alignment, listener);
			add(action);
		}
	}

	public void setSelection(Alignment alignment) {
		for (Action action : getActions()) {
			AlignmentAction alignmentAction = (AlignmentAction) action;
			if (alignmentAction.getAlignment() == alignment) {
				setSelected(action);
				return;
			}
		}
	}
	
}
